﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using System.Data;
using System.Data.OleDb;

public partial class add_guest_type : System.Web.UI.Page
{
    OleDbConnection conx;

    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        try
        {
            String con = "Provider=MSDAORA;Data Source=orcl;Password=oracle;User ID=pearl";//"DSN=orcl;Driver={Microsoft ODBC for Oracle};UID=system;PWD=password;SERVER=localhost;";
            conx = new OleDbConnection(con);
            conx.Open();

            if (conx.State == ConnectionState.Open)
            {
                Label1.Text = "Oracle Connected";

                string tb1 = TextBox1.Text;
                string tb2 = TextBox2.Text;
                string tb3 = TextBox3.Text;

                TextBox1.Text = "";
                TextBox2.Text = "";
                TextBox3.Text = "";

                DataSet ds = new DataSet("Dataset1");


                OleDbCommand ODC = new OleDbCommand("INSERT INTO GUEST_TYPE VALUES('" + tb1 + "','" + tb2 + "'," + Convert.ToInt32(tb3) + ")", conx);
                ODC.ExecuteNonQuery();
                Label1.Text = "\"New Guest Type Inserted\"";

                //OleDbCommand ODC = new OleDbCommand("INSERT INTO PRENAMES VALUES("+tb1+","+tb2+");", conx);
                //ODC.ExecuteNonQuery();
                //Label1.Text = Label1.Text + "Inserted " +ODC.ExecuteNonQuery()+" rows.";
            }
            else
                Label1.Text = "Oracle Connect Failed";

        }

        catch (Exception ex)
        {
            Label1.Text = ex.Message + "<br />" + ex.StackTrace;
        }

        finally
        {
            conx.Close();
            conx = null;
        }

    }
    protected void Button2_Click(object sender, EventArgs e)
    {
        TextBox1.Text = "";
        TextBox2.Text = "";
        TextBox3.Text = "";
    }
    protected void Button3_Click(object sender, EventArgs e)
    {
        Response.Redirect("view_list_guest_type.aspx");
    }
    protected void Button4_Click(object sender, EventArgs e)
    {
        Response.Redirect("addtype.aspx");
    }
}